<template>
  <div class="page_root" :key="queryUpdateFlag" data-page-name="工单任务日报审批详情页" data-page-identification="t_0qmx2r0fpk">
    <a-spin :spinning="pageLoading.loading" :tip="pageLoading.tip">
      <!-- begin vid_uxpvwba9ur 容器_mdhrfxo8ha -->
      <al-box class="vid_uxpvwba9ur">
        <!-- begin vid_qda7xszz78 容器_pa5tx52lro -->
        <al-box class="vid_qda7xszz78">
          <!-- begin vid_sfilmvv65x 工单日报审批详情 -->
          <span class="vid_sfilmvv65x"> 工单日报审批详情 </span>
          <!-- end vid_sfilmvv65x 工单日报审批详情 -->
        </al-box>
        <!-- end vid_qda7xszz78 容器_pa5tx52lro -->
        <!-- begin vid_og2ye6k7kb 布局容器_pyvdn6q6iw -->
        <a-row class="vid_og2ye6k7kb" :slots="'24'">
          <a-col :span="24">
            <!-- begin vid_iwcyr4i375 工单标题： -->
            <span class="vid_iwcyr4i375"> 工单标题： </span>
            <!-- end vid_iwcyr4i375 工单标题： -->
            <!-- begin vid_zqjezxqu9b 简单文本_n8z2syxfny -->
            <span class="vid_zqjezxqu9b">
              {{ renderStringInTemplate(vid_zqjezxqu9b_props.rt_text) }}
            </span>
            <!-- end vid_zqjezxqu9b 简单文本_n8z2syxfny -->
          </a-col>
        </a-row>
        <!-- end vid_og2ye6k7kb 布局容器_pyvdn6q6iw -->
        <!-- begin vid_t64bk0nb4b 布局容器_c0xjhzo91s -->
        <a-row class="vid_t64bk0nb4b" :slots="'24'">
          <a-col :span="24">
            <!-- begin vid_fpq9l60tc6 所属父工单标题： -->
            <span class="vid_fpq9l60tc6"> 所属父工单标题： </span>
            <!-- end vid_fpq9l60tc6 所属父工单标题： -->
            <!-- begin vid_32uu36jw2j 简单文本_02c7ogrgfj -->
            <span class="vid_32uu36jw2j">
              {{ renderStringInTemplate(vid_32uu36jw2j_props.rt_text) }}
            </span>
            <!-- end vid_32uu36jw2j 简单文本_02c7ogrgfj -->
          </a-col>
        </a-row>
        <!-- end vid_t64bk0nb4b 布局容器_c0xjhzo91s -->
        <!-- begin vid_v7u77flpai 布局容器_7y97lv6c18 -->
        <a-row class="vid_v7u77flpai" :gutter="16" :slots="'6:6:6:6'">
          <a-col :span="6">
            <!-- begin vid_6lntqyiog4 工时： -->
            <span class="vid_6lntqyiog4"> 工时： </span>
            <!-- end vid_6lntqyiog4 工时： -->
            <!-- begin vid_ezw58kqcyp 简单文本_mgqdq42zoh -->
            <span class="vid_ezw58kqcyp">
              {{ renderStringInTemplate(vid_ezw58kqcyp_props.rt_text) }}
            </span>
            <!-- end vid_ezw58kqcyp 简单文本_mgqdq42zoh -->
          </a-col>
          <a-col :span="6">
            <!-- begin vid_x9zl95q2xm 工时对应时间： -->
            <span class="vid_x9zl95q2xm"> 工时对应时间： </span>
            <!-- end vid_x9zl95q2xm 工时对应时间： -->
            <!-- begin vid_3tdt5tpv5u 简单文本_e5ynde48u2 -->
            <span class="vid_3tdt5tpv5u">
              {{ renderStringInTemplate(vid_3tdt5tpv5u_props.rt_text) }}
            </span>
            <!-- end vid_3tdt5tpv5u 简单文本_e5ynde48u2 -->
          </a-col>
          <a-col :span="6">
            <!-- begin vid_22gc80vudq 提交审批时间： -->
            <span class="vid_22gc80vudq"> 提交审批时间： </span>
            <!-- end vid_22gc80vudq 提交审批时间： -->
            <!-- begin vid_e3wzfzcg99 简单文本_feagkl8qmb -->
            <span class="vid_e3wzfzcg99">
              {{ renderStringInTemplate(vid_e3wzfzcg99_props.rt_text) }}
            </span>
            <!-- end vid_e3wzfzcg99 简单文本_feagkl8qmb -->
          </a-col>
          <a-col :span="6"> </a-col>
        </a-row>
        <!-- end vid_v7u77flpai 布局容器_7y97lv6c18 -->
      </al-box>
      <!-- end vid_uxpvwba9ur 容器_mdhrfxo8ha -->
    </a-spin>
  </div>
</template>
<script setup lang="tsx">
  import {
      h, ref, reactive, toRaw, markRaw, watch, computed,
      onBeforeMount, onMounted, onBeforeUnmount, onUnmounted, onActivated, onDeactivated
    } from "vue";
    import { useRoute, useRouter } from 'vue-router';
    const router = useRouter();
    const route = useRoute();
    import { get, post, put, del, request, requestWithHeaders } from '@/utils/http/Axios';
    import { cloneDeep, localGet, merge, getDifferenceArray, traversalTreeStructure, checkCaseCondition, renderStringInTemplate, handleBreadcrumbJump, throttle, permission, getComponentParamsValue } from '@/utils/index';
    import { isNullOrEmpty, isEmptyArr, isNullOrUnDef, isContained, isArray, isEmpty, isObject } from '@/utils/is';
    import dayjs from 'dayjs';
    import { getPagePcChartsDataSourceConvert } from '@/utils/chart';
    import { message, notification, Modal } from 'ant-design-vue'
    import { propertyFormatByNumber, propertyFormatByPercentage, propertyFormatByDate, parseSubFromDataList } from '@/utils/format';
    import colorTheme from '@/design/custom-theme.json';
    
    import UserTableRecords from '@/model/UserTableRecords';
    import { getAppBaseUrl } from '@/utils/index';
    import { sendToken } from "@/hooks/useIframeToken";
    import { useSystemStore } from "@/store/modules/system";
    const systemStore = useSystemStore();
    



      // 获取传入的流程ID和组件参数
      const props = defineProps({
            'processInstanceId': {
            type: [String,Number,Boolean],
            default: undefined,
        },
      })
      const immediateWatch = (source, callback) => {
        watch(source, callback, {deep: true,immediate: true })
      }



  /* -------------------------- 属性定义 -------------------------- */

      const setTimeOutList = [];
      const pageLoading = reactive({
        loading: false,
        tip: undefined
      });
      const authInfo = localGet('app-user-store');

    const vid_zqjezxqu9b_props = reactive({
          rt_text: undefined,
  })

    const vid_32uu36jw2j_props = reactive({
          rt_text: undefined,
  })

    const vid_ezw58kqcyp_props = reactive({
          rt_text: undefined,
  })

    const vid_3tdt5tpv5u_props = reactive({
          rt_text: undefined,
  })

    const vid_e3wzfzcg99_props = reactive({
          rt_text: undefined,
  })



      // 处理校验
      const setSubFormName =(parentInfo, name)=>{
        return [parentInfo.parents, parentInfo.cycleIndex, name];
      }


  /* ========================== 属性定义 ========================== */


  /* -------------------------- 元素数据引用 -------------------------- */


  /* ========================== 元素数据引用 ========================== */


  /* -------------------------- 页面数据 -------------------------- */

    // 页面数据 批量延时任务审批详情
    const dataConnector_conn_jr1t79xe0y_response = ref();
    const dataConnector_conn_jr1t79xe0y = async (additionParams = {}) => {
        const exec = async () => {
          // 获取参数
          const params = {

          };

          // 注入附加的参数
          try {
            merge(params, additionParams);
          } catch (error) {
            console.log(error)
          }

          // 判断加载提示
          message.loading({content:"加载中",duration: 0, key:"loading_hnr2r4n7bs"})
          // 处理URL
          let url = '/solution-ppm/api/v2/built-in-system-ppm/delivery_task/task_batch_delay/{instanceId}';
          // 替换url中的变量
          url = url.replace('{instanceId}', String(pageParameter_state.processInstanceId))
          // 排除空参数  日期组件重置后的空参数是[null] 或者[undefined]
          Object.keys(params).forEach(key=>{ if(params[key] === null){ delete params[key] }else if( Object.prototype.toString.call(params[key]) === '[object Object]' ){ Object.keys(params[key]).forEach(childKey=>{ if(params[key][childKey] === null || (Array.isArray(params[key][childKey]) && params[key][childKey].length === 1 && isNullOrUnDef(params[key][childKey]?.[0]))){ delete params[key][childKey] }}) } });
          return get(url, params, {
                headers: {}
              }).then(async (resp) => {
            dataConnector_conn_jr1t79xe0y_response.value = resp;

            return resp;
          }).catch(async (e) => {
            message.loading({content:"加载中",duration: 0.1, key:"loading_hnr2r4n7bs"})

            return Promise.reject(e);
          }).finally(async () => {
            message.loading({content:"加载中",duration: 0.1, key:"loading_hnr2r4n7bs"})

          })
        }

          return await exec()

    }


    // 页面数据 工时日报审批流查询
    const dataConnector_conn_i9giyr523r_response = ref();
    const dataConnector_conn_i9giyr523r = async (additionParams = {}) => {
        const exec = async () => {
          // 获取参数
          const params = {

          };

          // 注入附加的参数
          try {
            merge(params, additionParams);
          } catch (error) {
            console.log(error)
          }

          // 判断加载提示

          // 处理URL
          let url = '/solution-ppm/api/v2/built-in-system-ppm/daily/work-order-approval-process-search/{processInstanceId}';
          // 替换url中的变量
          url = url.replace('{processInstanceId}', String(pageParameter_state.processInstanceId))
          // 排除空参数  日期组件重置后的空参数是[null] 或者[undefined]
          Object.keys(params).forEach(key=>{ if(params[key] === null){ delete params[key] }else if( Object.prototype.toString.call(params[key]) === '[object Object]' ){ Object.keys(params[key]).forEach(childKey=>{ if(params[key][childKey] === null || (Array.isArray(params[key][childKey]) && params[key][childKey].length === 1 && isNullOrUnDef(params[key][childKey]?.[0]))){ delete params[key][childKey] }}) } });
          return get(url, params, {
                headers: {}
              }).then(async (resp) => {
            dataConnector_conn_i9giyr523r_response.value = resp;

            return resp;
          }).catch(async (e) => {


            return Promise.reject(e);
          }).finally(async () => {


          })
        }

          return await exec()

    }


  /* ========================== 页面数据 ========================== */



  /* -------------------------- 响应 -------------------------- */

  /* ========================== 响应 ========================== */


  /* -------------------------- 函数 -------------------------- */

  /* ========================== 函数 ========================== */


  /* -------------------------- 页面参数 -------------------------- */

    const pageParameter_state = reactive({
        'processInstanceId': props.processInstanceId ?? route.query.processInstanceId,
    })

  /* ========================== 页面参数 ========================== */


  /* -------------------------- 组件事件处理方法 -------------------------- */

    // ---------------------------- 组件数据同步 ----------------------------
    // 处理 简单文本_n8z2syxfny 的 rt_text 属性关联
  watch(() => dataConnector_conn_i9giyr523r_response?.value?.data?.content,
    () => {
      let dataList = dataConnector_conn_i9giyr523r_response?.value?.data?.content

      vid_zqjezxqu9b_props.rt_text = dataList;
    },
    {deep: true})
  // 处理 简单文本_02c7ogrgfj 的 rt_text 属性关联
  watch(() => dataConnector_conn_i9giyr523r_response?.value?.data?.parentContent,
    () => {
      let dataList = dataConnector_conn_i9giyr523r_response?.value?.data?.parentContent

      vid_32uu36jw2j_props.rt_text = dataList;
    },
    {deep: true})
  // 处理 简单文本_mgqdq42zoh 的 rt_text 属性关联
  watch(() => dataConnector_conn_i9giyr523r_response?.value?.data?.workingHours,
    () => {
      let dataList = dataConnector_conn_i9giyr523r_response?.value?.data?.workingHours

      vid_ezw58kqcyp_props.rt_text = dataList;
    },
    {deep: true})
  // 处理 简单文本_e5ynde48u2 的 rt_text 属性关联
  watch(() => dataConnector_conn_i9giyr523r_response?.value?.data?.dailyDate,
    () => {
      let dataList = dataConnector_conn_i9giyr523r_response?.value?.data?.dailyDate

      vid_3tdt5tpv5u_props.rt_text = dataList;
    },
    {deep: true})
  // 处理 简单文本_feagkl8qmb 的 rt_text 属性关联
  watch(() => dataConnector_conn_i9giyr523r_response?.value?.data?.submissionTime,
    () => {
      let dataList = dataConnector_conn_i9giyr523r_response?.value?.data?.submissionTime

      vid_e3wzfzcg99_props.rt_text = dataList;
    },
    {deep: true})
    // ============================ 组件数据同步 ============================


  /* ========================== 组件事件处理方法 ========================== */


  /* -------------------------- 生命周期 -------------------------- */
  // 用于参数变更后重新执行自定义指令
      const queryUpdateFlag = ref(0);
      onMounted(() => { ;dataConnector_conn_jr1t79xe0y()
  dataConnector_conn_i9giyr523r()

    });

    onUnmounted(() => {
      // 销毁定时器
      setTimeOutList.forEach(({ repeat, timer }) => {
        repeat ?  clearInterval(timer): clearTimeout(timer);
      });
    });

  /* ========================== 生命周期 ========================== */


  /* -------------------------- 数据关联处理 -------------------------- */





  /* -------------------------- 表单数据同步 -------------------------- */
  /* ========================== 表单数据同步 ========================== */

  /* ========================== 数据关联处理 ========================== */


  /* -------------------------- 不同组件自定义的处理逻辑 -------------------------- */

  /* ========================== 不同组件自定义的处理逻辑 ========================== */


  // ================================定制化逻辑========================================
  // 附件下载
  const ppmEnclosureInfoList = ref([])
  const taskId = ref(undefined)
  watch(() => dataConnector_conn_a4lxn61ico_response?.value,
    () => {
      ppmEnclosureInfoList.value = dataConnector_conn_a4lxn61ico_response?.value?.data.ppmEnclosureInfoList
      console.log(dataConnector_conn_a4lxn61ico_response?.value);
      console.log(ppmEnclosureInfoList.value,'ppmEnclosureInfoList');
    },
    { deep: true })
  console.log('14.20')
  pageLoading.tip = '正在下载请稍后...'
  // 图片预览

  const stateF = reactive({
    previewVisible: false,
    previewImage: '',
    previewFileUrl: '',
    isImagePreview: false
  })

  function previewAttachment(item) {
    // 检查附件类型
    if (item.type.startsWith('image')) {
      stateF.isImagePreview = true
      stateF.previewImage = item.url // 设置预览图片的URL
      stateF.previewVisible = true // 显示模态框
    } else {
      // stateF.isImagePreview = false;
      // // 如果是其他类型的文件，直接在模态框中显示
      // stateF.previewFileUrl = item.url; // 设置预览文件的URL
      message.info('目前仅支持图片预览')
    }
  }

  function handlerDownload({ url, name }) {
    pageLoading.loading = true

    function downBlob(blob) {
      const downloadElement = document.createElement('a')
      const href = window.URL.createObjectURL(blob) // 创建下载的链接
      downloadElement.href = href
      downloadElement.download = name // 下载后文件名
      document.body.appendChild(downloadElement)
      downloadElement.click() // 点击下载
      document.body.removeChild(downloadElement) // 下载完成移除元素
      window.URL.revokeObjectURL(href)
    }

    const data = new FormData()
    data.append('path', url)
    post('/solution-ppm/api/v2/built-in-system-ppm/delivery_task/downloadFile', data, {
      responseType: 'blob',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    })
      .then(blob => {
        downBlob(blob)
      })
      .finally(() => {
        pageLoading.loading = false
      })
  }

  function downloadZip(response, name) {
    const blob = new Blob([response], { type: 'application/zip;charset=utf-8' });
    const downloadElement = document.createElement('a');
    const href = window.URL.createObjectURL(blob);
    downloadElement.href = href;
    downloadElement.download = name; // 下载后文件名
    document.body.appendChild(downloadElement);
    downloadElement.click();
    document.body.removeChild(downloadElement);
    window.URL.revokeObjectURL(href);
    return href;
  }

   watch(() => dataConnector_conn_a4lxn61ico_response?.value?.data?.taskStatus,
   () => {
     let dataList = dataConnector_conn_a4lxn61ico_response?.value?.data?.taskStatus

  //
  let text = document.querySelector('.vid_9zk7il8n5j')
  if(dataList==='完成'){
      text.style.color = '#30BF78'
  }else if(dataList==='延期'){
      text.style.color = '#E02020'
  }else if(dataList==='进行中'){
      text.style.color = '#3875FF'
  }else if(dataList==='延期完成'){
      text.style.color = '#FF9846'
  }else if(dataList==='未启动'){
      text.style.color = '#8C8C8C'
  }
  //
   },
   {deep: true})
</script>
<style lang="less" scoped>
  .page_root {
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color:#F5F5F5;
  }
  .page_root :deep(.@{ant-prefix}-spin-nested-loading),
  .page_root :deep(.@{ant-prefix}-spin-container)
   {
      height: 100%;
  }
  .page_root :deep(.@{ant-prefix}-spin-container .@{ant-prefix}-table-wrapper)
   {
      display: flex;
      flex-flow: column nowrap;
      justify-content: flex-start;
  }
  .page_root :deep(.@{ant-prefix}-table)
   {
    flex: auto;
    overflow: auto;
  }
  .table-moreBtn_down {
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis; width: 100px;
  }

  .table-moreBtn_menu :deep(.table-moreBtn_menu-item):hover {
    background: #ebf1ff;
  }

  /*  表格树结构样式处理，展开按钮层级增加*/
  :deep(.@{ant-prefix}-table-row-expand-icon) {
    z-index: 1;
  }
  /*  表格树结构 由于每个表格项采用自定义组件，使用绝对定位布局，开启树结构导致显示异常，暂时使用层级定位位置 */
  :deep(.@{ant-prefix}-table-row-level-1 .@{ant-prefix}-table-cell-with-append .cell-wrapper-left) {
    left: 15px !important;
    width: calc(100% - 15px);
  }
  :deep(.@{ant-prefix}-table-row-level-2 .@{ant-prefix}-table-cell-with-append .cell-wrapper-left) {
    left: 30px !important;
    width: calc(100% - 30px);
  }
  :deep(.@{ant-prefix}-table-row-level-3 .@{ant-prefix}-table-cell-with-append .cell-wrapper-left) {
    left: 45px !important;
    width: calc(100% - 45px);
  }
  :deep(.@{ant-prefix}-table-row-level-4 .@{ant-prefix}-table-cell-with-append .cell-wrapper-left) {
    left: 60px !important;
    width: calc(100% - 60px);
  }

  /* 穿梭框改变默认样式，为根据组件样式控制左右栏宽度。 */
  :deep(.@{ant-prefix}-transfer-list)
   {
      height: 100%;
      width: 50%;
  }
  .vid_uxpvwba9ur{
      height:750px;
      display:block;
      background-color:#FFFFFF;
      box-shadow:0px 0px 0px 0px ;
      border-radius:4px
  }
  .vid_qda7xszz78{
      margin-bottom:16px;
      background-color:#FFFFFF
  }
  .vid_sfilmvv65x{
      height:16px;
      display:flex;
      align-items:center;
      flex-wrap:undefined;
      padding-left:8px;
      font-weight:600;
      font-size:16px;
      border-left-style:solid;
      border-left-width:4px;
      border-left-color:#3875FF
  }
  .vid_og2ye6k7kb{
      display:flex;
      flex-direction:row;
      align-items:center;
      flex-wrap:undefined;
      margin-bottom:8px;
      box-shadow:0px 0px 0px 0px
  }
  .vid_iwcyr4i375{
      min-width:70px;
      font-family:arial, helvetica, "microsoft yahei";;
      font-weight:400;
      color:rgba(89, 89, 89, 1)
  }
  .vid_zqjezxqu9b{
      font-weight:600;
      color:rgba(38, 38, 38, 1)
  }
  .vid_t64bk0nb4b{
      display:flex;
      flex-direction:row;
      align-items:center;
      flex-wrap:undefined;
      margin-bottom:8px;
      box-shadow:0px 0px 0px 0px
  }
  .vid_fpq9l60tc6{
      min-width:70px;
      font-family:arial, helvetica, "microsoft yahei";;
      font-weight:400;
      color:rgba(89, 89, 89, 1)
  }
  .vid_32uu36jw2j{
      font-weight:600;
      color:rgba(38, 38, 38, 1)
  }
  .vid_v7u77flpai{
      display:flex;
      flex-direction:row;
      align-items:center;
      flex-wrap:nowrap
  }
  .vid_6lntqyiog4{
      font-family:arial, helvetica, "microsoft yahei";;
      font-weight:400;
      color:rgba(89, 89, 89, 1)
  }
  .vid_ezw58kqcyp{
      font-weight:600;
      color:rgba(38, 38, 38, 1)
  }
  .vid_x9zl95q2xm{
      font-family:arial, helvetica, "microsoft yahei";;
      font-weight:400;
      color:rgba(89, 89, 89, 1)
  }
  .vid_3tdt5tpv5u{
      font-weight:600;
      color:rgba(38, 38, 38, 1)
  }
  .vid_22gc80vudq{
      font-family:arial, helvetica, "microsoft yahei";;
      font-weight:400;
      color:rgba(89, 89, 89, 1)
  }
  .vid_e3wzfzcg99{
      font-weight:600;
      color:rgba(38, 38, 38, 1)
  }

  :deep(.@{ant-prefix}-table-empty .@{ant-prefix}-table-tbody tr > td) {
   padding: 0;
  }
    /deep/.ant3-checkbox-group-item + .ant3-checkbox-group-item span{
      color:#595959 !important;
    }
    /deep/.ant3-checkbox-wrapper.ant3-checkbox-wrapper-disabled span{
      color:#595959 !important;
    }
  .file-item {
    display: flex;
    width: 100%;
  }
  .file-name {
    width: 75%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
  .file-time,
  .file-preview,
  .file-download {
    width: 10%;
    text-align: center;
    cursor: pointer;
  }
  .file-preview,
  .file-download {
    color: #3875ff;
  }
  .vid_qa53gc55by{
    height:197px;
    box-shadow:0px 0px 0px 0px;
    display: flex;
    flex-direction: column;
  }
  .file-main{
    width: 35%;
    overflow-y: scroll;
  }
</style>